<template>
	<view class="login pd-20">
		<view class="user mb-20">
			<view class="lognav">
				<view class="label" >账号：</view>
				<input type="text" class="inputnav" placeholder="请输入手机号" v-model="u.tel" />
			</view>
			<view class="lognav">
				<view class="label" >密码：</view>
				<input type="password"  class="inputnav" placeholder="请输入密码" v-model="u.password" />
			</view>
			<view class="lognav" @click="adduser">
				注册账号
			</view>
		</view>
		<view class="loginbut">
			<button type="primary" class="mb-20"  open-type="getUserInfo" @click="login">登录</button>
		</view>
			
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				u:{
					tel:'',
					password:''
				}
			}
		},
		methods: {
					async login(e) {
					let data = this.u
					let res = await this.$api.getLogin(data)
					console.log(res.data)
					if(res.data.status==1){
						//缓存数据
						 uni.setStorageSync('uid', res.data.data.admin_id);
						 uni.setStorageSync('nickname', res.data.data.account);
						  uni.setStorageSync('tstatus', res.data.data.tstatus);
						uni.switchTab({
							url:'/pages/index/index'
						})	
					}else {
						uni.showToast({
						  title: '请重新登陆',
						  icon:'error',
						  duration: 2000
						});
					}
				},
				adduser(){
					uni.navigateTo({
						url:'/pages/adduser/adduser'
					})
				}
				
				
			}
		
	}
</script>

<style lang="scss">
	.lognav{
		width: 100%;
		height: 70px;
		padding: 10rpx;
		margin-bottom: 10px;
	}
	.inputnav{
			border: 1rpx solid #555555;
			height: 30px;
			padding: 10rpx;
			margin: 10px;
			border-radius: 5px;
		}
		.label{
			width: 30%;	
		}
		.loginbut{
			width: 60%;
			margin: 0 auto;
		}
</style>
